<template>
  <div>
    <el-table :data="list" style="width: 100%">
      <el-table-column label="序号" width="100">
        <template slot-scope="scope">
          <span>{{scope.$index + 1}}</span>
        </template>
      </el-table-column>
      <el-table-column label="不合法类型" prop="jubao.typetext" width="280"></el-table-column>
      <el-table-column label="用户名" prop="user.nickname" width="180"></el-table-column>
      <el-table-column label="评论内容" prop="comment" width="280"></el-table-column>
      <el-table-column label="反馈内容" prop="jubao.content" width="280"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="danger"
            v-if="scope.row.iscomment"
            @click="deleteComment(scope.$index, scope.row)"
          >删除相关评论</el-button>
          <el-button
            size="mini"
            type="defalut"
            v-if="!scope.row.iscomment"
            @click="lookUser(scope.$index, scope.row)"
          >查看该用户</el-button>
          <el-button
            size="mini"
            type="danger"
            v-if="!scope.row.iscomment"
            @click="dongjieUser(scope.$index, scope.row)"
          >冻结该用户</el-button>
          <el-button
            size="mini"
            type="default"
            @click="hulve(scope.$index, scope.row)"
          >忽略</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog title="用户信息" :visible.sync="userdialogVisible" width="30%">
      <el-form :model="form" label-width="80px">
        <el-form-item label="账户名">
          <el-input v-model="form.username" disabled></el-input>
        </el-form-item>
        <el-form-item label="用户名">
          <el-input v-model="form.nickname" disabled></el-input>
        </el-form-item>
        <el-form-item label="头像">
          <img
            :src="'http://localhost:8010/getImage?name='+form.avataurl"
            alt
            style="border-radius:100px;height:100px;width:100px;"
          />
        </el-form-item>
        <el-form-item label="简介">
          <el-input :rows="3" v-model="form.intro" type="textarea" disabled></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="userdialogVisible = false">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  layout: "admin",
  data() {
    return {
      list: [],
      userdialogVisible: false,
      form: {}
    };
  },
  created() {
    this.refreshlist();
  },
  methods: {
    refreshlist() {
      this.$axios.get("/api2/jubao/list").then(res => {
        this.list = res.data;
      });
    },
    deleteComment(index, item) {
      this.$axios.get("/api2/jubao/delete?id=" + item.jubao.id).then(Res => {
        this.refreshlist();
      });
    },
    lookUser(index, row) {
      this.form = JSON.parse(JSON.stringify(row.user));
      this.userdialogVisible = true;
    },
    hulve(index, row) {
      this.$axios.get("/api2/jubao/hulve?id="+row.jubao.id).then(res=>{
        this.refreshlist()
      })
    },
    dongjieUser(index, item){
       this.$axios.get("/api2/jubao/dongjie?id=" + item.jubao.id).then(Res => {
        this.refreshlist();
      });
    }
  }
};
</script>

<style>
</style>